
{block name="css"}

<link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui/css/H-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui.admin/css/H-ui.admin.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/lib/Hui-iconfont/1.0.8/iconfont.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/hui/static/h-ui.admin/skin/default/skin.css" id="skin"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/common.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/app.css"/>

{CSS href="__STATIC__/admin/uploadify/uploadify.css" /}
{CSS href="__STATIC__/w/admin_base.css" /}
{CSS href="__STATIC__/w/icon.css" /}
{CSS href="__STATIC__/w/layui.css" /}
{CSS href="__STATIC__/w/divtable.css" /}
{/block}

{block name="js"}
{js href='__STATIC__/w/jquery1110min.js' /}
{js href='__STATIC__/w/layui.js' /}
{js href='__STATIC__/admin/hui/lib/layer/2.4/layer.js' /}
{/block}

{block name="main"}

<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 自动回复
    <span class="c-gray en">&gt;</span> 添加关键字
    <a class="btn radius btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>

<form class="layui-form layui-form-cont" action="">

    <div class="layui-form-title">
        添加关键字
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">回复关键词</label>
        <div class="layui-input-block">
            <input type="text" name="keyword" placeholder="请输入关键词" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否开启</label>
        <div class="layui-input-block">
            <input type="checkbox" name="status" value="1" checked="checked" lay-skin="switch">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">回复类型</label>
        <div id="replyType" class="layui-input-block">
            <input type="radio"  checked  name="type" value="text" title="回复文本">
            <input type="radio" name="type" value="news" title="回复图文" >
            <!--<input type="radio" name="type" value="addon" title="触发应用">-->
            <input type="radio" name="type" value="voice" title="回复语音" >
            <input type="radio" name="type" value="image" title="回复图片" >
            <input type="radio" name="type" value="video" title="回复视频">
            <input type="radio" name="type" value="music" title="回复音乐" >
        </div>
    </div>

    <div id="tapNode">
        <div class="layui-tab-content" style="margin-top: 0;">
            <div class=" reply_text layui-tab-item layui-show"><div class="layui-form-item layui-form-text">
                <label class="layui-form-label">回复内容</label>
                <div class="layui-input-block">
                    <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>

                </div>
            </div>
            </div>

            <div class="reply_news layui-tab-item">

                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">封面图</label>
                    <div class="layui-input-block">
                        <div id="news_s"><img src="__PUBLIC__/uploads/{$data.url ?'addkey/'.$data.url: 'sm_300.jpg'}" width="200px" height="200px"/></div>
                        <input id="news_post" name="picurl" type="hidden" value="{$data.url ?? ''}"/>
                        <input name="news_old_image" type="hidden" value="{$data.url ?? ''}"/>
                        <input id="news" name="image_upload" type="file" multiple="true">
                        <!--<BR><span onclick="getMaterial('picurl','image')" class="layui-btn radius layui-btn-primary btn-sc"><i class="layui-icon">&#xe654;</i>选择素材</span>-->
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">图文描述</label>
                    <div class="layui-input-block">
                        <!--<script id="reply_news" type="text/plain" name="news_content" style="width:100%;height:400px;"></script>-->

                        <textarea name="news_content" placeholder="请输入图文描述" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">连接地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="link"  placeholder="请输入连接地址如：http://xxxx.com/……" autocomplete="off" class="layui-input">
                    </div>
                </div>

            </div>
            <div class="reply_addon layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">选择应用</label>
                    <div class="layui-input-block">
                        <select name="addons">
                            <option value="">请选择应用</option>
                            {volist name="addons" id="v"}
                            <option value="{$v.addon}">{$v.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
            </div>
            <div class="reply_voice layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">语音名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="voice_title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">

                    <label class="layui-form-label">语音</label>
                    <div class="layui-input-block">
                                <input class="layui-input" readonly="readonly" name="voice" id="voice_post" value="{$data.url ?? ''}"/>
                                <input id="voice" name="file_upload" type="file" multiple="true">
                                <input name="old_voice" type="hidden" value="{$data.url ?? ''}">
                        <p class="tip_for_p">临时语音只支持amr/mp3格式,大小不超过为2M,长度不超过60秒,永久语音只支持mp3/wma/wav/amr格式,大小不超过为5M,长度不超过60秒</p>
                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div  class="layui-input-block">
                        <input type="radio"  checked  name="voice_staus_type" value="0" title="临时">
                        <input type="radio" name="voice_staus_type" value="1" title="永久" >
                    </div>
                </div>
            </div>
            <div class="reply_image layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">上传图片</label>
                    <div class="layui-input-block">
                                <div id="image_s"><img src="__PUBLIC__/uploads/{$data.url ?'addkey/'.$data.url: 'sm_300.jpg'}" width="200px" height="200px"/></div>
                                <input id="image_post" name="reply_image" type="hidden" value="{$data.url ?? ''}"/>
                                <input name="old_image" type="hidden" value="{$data.url ?? ''}"/>
                                <input id="image" name="image_upload" type="file" multiple="true">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div  class="layui-input-block">
                        <input type="radio"  checked  name="image_staus_type" value="0" title="临时">
                        <input type="radio" name="image_staus_type" value="1" title="永久" >
                    </div>
                </div>
            </div>
            <div class="reply_video layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">视频标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="video_title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">视频</label>
                    <div class="layui-input-block">
                                <input  class="layui-input" readonly="readonly" name="reply_video" id="video_post" value="{$data.url ?? ''}" />
                                <input id="video" name="file_upload" type="file" multiple="true">
                                <input name="old_video" type="hidden" value="{$data.url ?? ''}">
                                <div id="queue"></div>
                                <a href="__PUBLIC__/uploads/addkey/{$data.url ?? ''}">{$data.url ?'下载': ''}</a>
                        <p class="tip_for_p">临时视频只支持mp4格式,大小不超过为10M,永久视频只支持rm/rmvb/wmv/avi/mpg/mpeg/mp4格式,大小不超过为20M</p>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述内容</label>
                    <div class="layui-input-block">
                        <textarea name="video_content" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div  class="layui-input-block">
                        <input type="radio"  checked  name="video_staus_type" value="0" title="临时">
                        <input type="radio" name="video_staus_type" value="1" title="永久" >
                    </div>
                </div>
            </div>
            <div class="reply_music layui-tab-item">
                <div class="layui-form-item">
                    <label class="layui-form-label">音乐标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="music_title"  placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">资源文件</label>
                    <div class="layui-input-block">
                                <input  class="layui-input" readonly="readonly" name="music" id="music_post" value="{$data.url ?? ''}" />
                                <input id="music" name="file_upload" type="file" multiple="true">
                                <input name="old_music" type="hidden" value="{$data.url ?? ''}">
                    </div>

                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">高品质链接</label>
                    <div class="layui-input-block">
                        <input type="text" name="music_link"  placeholder="请输入链接" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述内容</label>
                    <div class="layui-input-block">
                        <textarea name="music_content" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>

            </div>
        </div>

    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="SBT">立即提交</button>
            <button type="reset" class="layui-btn radius layui-btn-primary">重置</button>
            <button type="button" class="layui-btn radius layui-btn-primary" onClick="window.history.back();">返回上一页</button>
        </div>
    </div>

</form>

<script>
    function getMaterial(paramName,type){
        layer.open({
            type: 2,
            title: '选择素材',
            shadeClose: true,
            shade: 0.8,
            area: ['700px', '320px'],
            content: '{:url("admin/Wechatmaterial/getMeterial","","")}/type/'+type+'/param/'+paramName //iframe的url
        });
    }
    function controllerByVal(value,paramName,type) {
        $('.form_'+paramName).attr('src',value);
        $("input[name="+paramName+"]").val(value);
    }
    $(function () {
        // $('input[name="type"]').each(function(){alert(this.value);});var oldClass= 'replay_'+ $("input[name='type']:checked").val();
        $("#replyType").click(function(){
            var class_a='reply_'+ $("input[name='type']:checked").val();
            $('.layui-tab-content div').removeClass('layui-show')
            $('.'+class_a).addClass('layui-show')
        });
    })
    layui.use('form', function(){
        var form = layui.form
        form.on('submit(SBT)', function(data){
            var load = layer.load();
            $.post('',data.field,function (res) {
                if(res.status=='0'){
                    layer.close(load);
                    layer.alert(res.msg);
                }
                if(res.status=='1'){
                    layer.close(load);
                    layer.msg(res.msg,{time:1000},function () {
                        window.location.href=res.url;
                    });
                }
            })
            return false;
        });

    });
</script>
{/block}

<!-- 下载文件 -->
<script src="__STATIC__/admin/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/upfile.js" type="text/javascript"></script>

<script type="text/javascript">
    upload_image('news','*.gif; *.jpg; *.png','300','300','500');
    upload_image('image','*.gif; *.jpg; *.png','300','300','500');
    upload_file('music','*.mp3; *.wma; *.wav; *.amr');
    upload_file('video','*.rm; *.rmvb; *.wmv; *.avi; *.mpg; *.mpeg; *.mp4');
    upload_file('voice','*.mp3; *.wma; *.wav; *.amr');

    var URL = {
        uploader: '{:url('Upload/addkeyfile')}',
        swf:'__STATIC__/admin/uploadify/uploadify.swf',
        ROOT:'__PUBLIC__/uploads/addkey',
    }
</script>